jQuery(document).ready(function($) {
    //轮播
    $('#J_slides').slide({
        mainCell: '.bd ul',
        autoPlay: true,
        effect: 'fold'
    });

    //日期选择
    $('#J_search_form .date').each(function(index, el) {
        new Pikaday({
            field: el,
            firstDay: 1,
            minDate: new Date(),
            i18n: {
                previousMonth : '上个月',
                nextMonth     : '下个月',
                months        : ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                weekdays      : ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
                weekdaysShort : ['日','一','二','三','四','五','六']
            },
            onSelect: function() {
                var date = new Date(this);
                var dateStr = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                el.value = dateStr;
            }
        });
    });

    //目的地选择
    $('#J_des').on('click', function(event) {
        event.stopPropagation();
        $('#J_des_list').show();
    });
    $(window).on('click', function(event) {
        event.preventDefault();
        $('#J_des_list').hide();
    });
    $('#J_des_list').on('click', 'span', function(event) {
        $('#J_des_list').hide();
        $('#J_des').val(this.innerText);
    });
});